package com.clear.honghefinance.admin.controller;

import com.clear.honghefinance.biz.modules.assist_calculate_summary.domain.dto.*;
import com.clear.honghefinance.biz.modules.assist_calculate_summary.domain.vo.*;
import com.clear.honghefinance.biz.modules.assist_calculate_summary.service.IAssistCalculateSummaryService;
import com.clear.honghefinance.common.dto.entity.ApiResponse;
import com.clear.honghefinance.common.dto.entity.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@Api(tags = "辅助核算管理")
@RestController
@RequestMapping(value = "/assistCalculateSummary")
@RequiredArgsConstructor
@Slf4j
public class AssistCalculateSummaryController {

    private final IAssistCalculateSummaryService assistCalculateSummaryService;

    /**
     * 创建自定义辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建自定义辅助核算")
    @PostMapping(value = "/createCustom")
    public ApiResponse<Boolean> createCustom(@Validated @RequestBody CreateAssistCalculateCustomDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建客户辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建客户辅助核算")
    @PostMapping(value = "/createCustomer")
    public ApiResponse<Boolean> createCustomer(@Validated @RequestBody CreateAssistCalculateCustomerDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建部门辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建部门辅助核算")
    @PostMapping(value = "/createDepartment")
    public ApiResponse<Boolean> createDepartment(@Validated @RequestBody CreateAssistCalculateDepartmentDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建职员辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建职员辅助核算")
    @PostMapping(value = "/createEmployee")
    public ApiResponse<Boolean> createEmployee(@Validated @RequestBody CreateAssistCalculateEmployeeDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建存货辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建存货辅助核算")
    @PostMapping(value = "/createInventory")
    public ApiResponse<Boolean> createInventory(@Validated @RequestBody CreateAssistCalculateInventoryDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建项目辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建项目辅助核算")
    @PostMapping(value = "/createProject")
    public ApiResponse<Boolean> createProject(@Validated @RequestBody CreateAssistCalculateProjectDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }

    /**
     * 创建供应商辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建供应商辅助核算")
    @PostMapping(value = "/createSupplier")
    public ApiResponse<Boolean> createSupplier(@Validated @RequestBody CreateAssistCalculateSupplierDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.create(dto));
    }


    // ====================================================================================================

    /**
     * 修改自定义辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改自定义辅助核算")
    @PostMapping(value = "/updateCustom")
    public ApiResponse<Boolean> updateCustom(@Validated @RequestBody UpdateAssistCalculateCustomDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改客户辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改客户辅助核算")
    @PostMapping(value = "/updateCustomer")
    public ApiResponse<Boolean> updateCustomer(@Validated @RequestBody UpdateAssistCalculateCustomerDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改部门辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改部门辅助核算")
    @PostMapping(value = "/updateDepartment")
    public ApiResponse<Boolean> updateDepartment(@Validated @RequestBody UpdateAssistCalculateDepartmentDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改职员辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改职员辅助核算")
    @PostMapping(value = "/updateEmployee")
    public ApiResponse<Boolean> updateEmployee(@Validated @RequestBody UpdateAssistCalculateEmployeeDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改存货辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改存货辅助核算")
    @PostMapping(value = "/updateInventory")
    public ApiResponse<Boolean> updateInventory(@Validated @RequestBody UpdateAssistCalculateInventoryDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改项目辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改项目辅助核算")
    @PostMapping(value = "/updateProject")
    public ApiResponse<Boolean> updateProject(@Validated @RequestBody UpdateAssistCalculateProjectDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    /**
     * 修改供应商辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "修改供应商辅助核算")
    @PostMapping(value = "/updateSupplier")
    public ApiResponse<Boolean> update(@Validated @RequestBody UpdateAssistCalculateSupplierDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.update(dto));
    }

    // ====================================================================================================

    @ApiOperation(value = "查询辅助核算列表")
    @PostMapping(value = "/list")
    public ApiResponse<PageResult<ListAssistCalculateSummaryVO>> list(@Validated @RequestBody ListAssistCalculateSummaryDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto));
    }

    /**
     * 查询自定义辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询自定义辅助核算列表")
    @PostMapping(value = "/listCustom")
    public ApiResponse<PageResult<ListAssistCalculateCustomVO>> listCustom(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateCustomVO.class));
    }

    /**
     * 查询客户辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询客户辅助核算列表")
    @PostMapping(value = "/listCustomer")
    public ApiResponse<PageResult<ListAssistCalculateCustomerVO>> listCustomer(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateCustomerVO.class));
    }

    @ApiOperation(value = "查询部门辅助核算列表")
    @PostMapping(value = "/listDepartment")
    public ApiResponse<PageResult<ListAssistCalculateDepartmentVO>> listDepartment(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateDepartmentVO.class));
    }

    /**
     * 查询职员辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询职员辅助核算列表")
    @PostMapping(value = "/listEmployee")
    public ApiResponse<PageResult<ListAssistCalculateEmployeeVO>> listEmployee(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateEmployeeVO.class));
    }

    /**
     * 查询存货辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询存货辅助核算列表")
    @PostMapping(value = "/listInventory")
    public ApiResponse<PageResult<ListAssistCalculateInventoryVO>> listInventory(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateInventoryVO.class));
    }

    /**
     * 查询项目辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询项目辅助核算列表")
    @PostMapping(value = "/listProject")
    public ApiResponse<PageResult<ListAssistCalculateProjectVO>> listProject(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateProjectVO.class));
    }

    /**
     * 查询供应商辅助核算列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询供应商辅助核算列表")
    @PostMapping(value = "/listSupplier")
    public ApiResponse<PageResult<ListAssistCalculateSupplierVO>> listSupplier(@Validated @RequestBody ListAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.list(dto, ListAssistCalculateSupplierVO.class));
    }

    // ====================================================================================================

    /**
     * 获取自定义辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取自定义辅助核算明细")
    @GetMapping(value = "/getCustom")
    public ApiResponse<GetAssistCalculateCustomVO> getCustom(@Validated @NotNull(message = "id不能为空")
                                                             @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateCustomVO.class));
    }

    /**
     * 获取客户辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取客户辅助核算明细")
    @GetMapping(value = "/getCustomer")
    public ApiResponse<GetAssistCalculateCustomerVO> getCustomer(@Validated @NotNull(message = "id不能为空")
                                                                 @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateCustomerVO.class));
    }

    /**
     * 获取部门辅助核算明细
     */
    @ApiOperation(value = "获取部门辅助核算明细")
    @GetMapping(value = "/getDepartment")
    public ApiResponse<GetAssistCalculateDepartmentVO> getDepartment(@Validated @NotNull(message = "id不能为空")
                                                                     @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateDepartmentVO.class));
    }

    /**
     * 获取职员辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取职员辅助核算明细")
    @GetMapping(value = "/getEmployee")
    public ApiResponse<GetAssistCalculateEmployeeVO> getEmployee(@Validated @NotNull(message = "id不能为空")
                                                                 @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateEmployeeVO.class));
    }

    /**
     * 获取存货辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取存货辅助核算明细")
    @GetMapping(value = "/getInventory")
    public ApiResponse<GetAssistCalculateInventoryVO> getInventory(@Validated @NotNull(message = "id不能为空")
                                                                   @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateInventoryVO.class));
    }

    /**
     * 获取项目辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取项目辅助核算明细")
    @GetMapping(value = "/getProject")
    public ApiResponse<GetAssistCalculateProjectVO> getProject(@Validated @NotNull(message = "id不能为空")
                                                               @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateProjectVO.class));
    }

    /**
     * 获取供应商辅助核算明细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取供应商辅助核算明细")
    @GetMapping(value = "/getSupplier")
    public ApiResponse<GetAssistCalculateSupplierVO> getSupplier(@Validated @NotNull(message = "id不能为空")
                                                                 @RequestParam Long id) {
        return ApiResponse.success(assistCalculateSummaryService.getDetailById(id, GetAssistCalculateSupplierVO.class));
    }

    // ====================================================================================================

    /**
     * 禁用或启用辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "禁用或启用辅助核算")
    @PostMapping(value = "/updateDisable")
    public ApiResponse<Boolean> updateDisable(@Validated @RequestBody UpdateAssistCalculateDisableDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.updateDisable(dto));
    }

    // ====================================================================================================

    /**
     * 删除辅助核算
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "删除辅助核算")
    @PostMapping(value = "/del")
    public ApiResponse<Boolean> del(@Validated @RequestBody DeleteAssistCalculateDTO dto) {
        return ApiResponse.success(assistCalculateSummaryService.delete(dto));
    }
}